<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入1-100之间的整数">
<input type="button" value="猜一猜" onclick="f()">
<h3>
  结果：<span></span>
</h3>


<script>
//得到一个1-100之间的随机整数
let x=parseInt(Math.random()*100+1);
//得到文本框
let i = document.querySelector("input");
let s = document.querySelector("span");
let count=0;
function f() {
    count++;
  if(i.value>x){
    s.innerText="猜大了！";

  }
  else if (i.value<x){
    s.innerText="猜小了！";

  }
  else{
    s.innerText="恭喜你猜对了！这是您猜了第"+count+"次，猜对了！"
  }
}
</script>
</body>
</html>